cmake_minimum_required(VERSION 3.19)
project(SRMediaPlayer LANGUAGES CXX)

find_package(Qt6 6.5 REQUIRED COMPONENTS Core Widgets Multimedia MultimediaWidgets)  # 添加媒体模块
find_package(Qt6 REQUIRED COMPONENTS Core)

qt_standard_project_setup()

# 添加 ffmpeg 头文件路径
include_directories(${CMAKE_SOURCE_DIR}/ffmpeg/include)

# 添加 ffmpeg 库路径
link_directories(${CMAKE_SOURCE_DIR}/ffmpeg/lib)

qt_add_executable(SRMediaPlayer
    WIN32 MACOSX_BUNDLE
    main.cpp
    srmediaplayer.cpp
    srmediaplayer.h
    srmediaplayer.ui
    mediaplaylist.h mediaplaylist.cpp
    mediaplaylist.h mediaplaylist.cpp
    image.qrc
    controlwidget.h controlwidget.cpp controlwidget.ui


)

target_link_libraries(SRMediaPlayer
    PRIVATE
        Qt::Core
        Qt::Widgets
        Qt::Multimedia
        Qt::MultimediaWidgets  # 链接多媒体widgets库
        avcodec
        avformat
        avutil
)
target_link_libraries(SRMediaPlayer PRIVATE Qt6::Core)

include(GNUInstallDirs)

install(TARGETS SRMediaPlayer
    BUNDLE  DESTINATION .
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

qt_generate_deploy_app_script(
    TARGET SRMediaPlayer
    OUTPUT_SCRIPT deploy_script
    NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})
